package exam.business.service;

import exam.common.constant.ResultPort;
import exam.common.key.KeyUser;
import exam.common.util.MD5;
import exam.common.util.NullCheckUtil;
import exam.model.dao.TUserDAO;
import exam.system.business.AbstractService;
import exam.system.business.BusinessServiceInfo;


public class UserLoginService extends AbstractService {
	private TUserDAO tUserDAO = new TUserDAO();	
	@Override
	public String executeService(BusinessServiceInfo serviceInfo)
			throws Exception {
		// username
		String userName = serviceInfo.getString(KeyUser.USER_NAME);
		// password
		String password = serviceInfo.getString(KeyUser.PASS_WORD_1);
		if(NullCheckUtil.isNull(userName)
				|| NullCheckUtil.isNull(password)) {
			return ResultPort.ERROR;
		}
		password = MD5.encryption(password);
		String login = tUserDAO.login(userName, password);
		serviceInfo.put(KeyUser.USER_NAME, login);
		return ResultPort.SUCCESS;
	}

}
